<?php
/*
 * class pbADP
*/
require_once (__PLU__ . 'protocolbuf/message/pb_message.php');

class pbADP {
	var $classHead = 'PB_PROTO_';
	
	function adp_init() {
		$this->classHead = V('o:PB/CLASS_HEAD');
	}
	
	function serialize($obj) {
		return $obj->SerializeToString();
	}
	
	function unserialize($string, $clsName = NULL) {
		$obj = new $clsName();
		$obj->ParseFromString($string);
		return $obj;
	}
	
	function createCls($protoFileHead) {
		require_once (__PLU__ . 'protocolbuf/parser/pb_parser.php');
		$classPath = __APP__ . 'var' . __SEP__ . 'pb' . __SEP__ . 'cls' . __SEP__;
		$protoPath = __APP__ . 'var' . __SEP__ . 'pb' . __SEP__ . 'proto' . __SEP__;
		$className = $this->classHead . $protoFileHead;
		$protoFile = $protoFileHead . '.proto';
		$pb = new PBParser();
		$pb->parse($protoPath . $protoFile, $this->classHead, $classPath);
	}
}
?>